<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    const arr = ['as','ad','ba','da','aa','ae','bb']
    console.log(arr);
    arr.sort()
    console.log(arr);
    const arr2 = [
      {name:'ad'},
      {name:'aa'},
      {name:'ba'},
    {name:'ag'}
    ]

    console.log(arr2);
    arr2.sort((a,b)=>{
      const aa = a.name
        const bb = b.name
        if (aa < bb) {
          return -1
        } else if (aa === bb) {
          return 0
        } else {
          return 1
        }
    })
    console.log(arr2);
  </script>
</body>
</html>